define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'user/team/index' + location.search,
                    // add_url: 'user/team/add',
                    // edit_url: 'user/team/edit',
                    // del_url: 'user/team/del',
                    // multi_url: 'user/team/multi',
                    // import_url: 'user/team/import',
                    table: 'user_team',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'ut_id',
                sortName: 'ut_id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'ut_id', title: __('Ut_id'),visible:false},
                        {field: 'user_id', title: __('User_id'),visible:false},
                        {field: 'user.username', title: __('User.username'), operate: 'LIKE'},
                        {field: 'user.nickname', title: __('User.nickname'), operate: 'LIKE'},
                        {field: 'team', title: __('Team'),visible:false},
                        {field: 'team_title', title: '组队名称',operate: false},
                        {field: 'is_store', title: '门店组队',searchList: {0:'否',1:'是'},operate: false},
                        {field: 'verif_code', title: __('Verif_code'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'state', title: __('State'), searchList: {"0":__('State 0'),"1":__('State 1'),"2":__('State 2'),"3":__('State 3')}, formatter: Table.api.formatter.normal},
                        {field: 'pay_state', title: __('Pay_state'), searchList: {"0":__('Pay_state 0'),"1":__('Pay_state 1'),"2":__('Pay_state 2')}, formatter: Table.api.formatter.normal},
                        {field: 'order_id', title: __('Order_id')},
                        {field: 'start', title: __('Start'), searchList: {"1":__('Start 1'),"0":__('Start 0')}, formatter: Table.api.formatter.normal},
                        {field: 'follow', title: __('Follow'), searchList: {"1":__('Follow 1'),"0":__('Follow 0')}, formatter: Table.api.formatter.normal},
                        {field: 'sign_id', title: __('Sign_id')},
                        {field: 'sign_name', title: '名片名称',operate: false},
                        {field: 'sign_mobile', title: '名片手机号',operate: false},
                        {field: 'write_off_id', title: __('Write_off_id')},
                        {field: 'is_system', title: __('Is_system'), searchList: {"0":__('Is_system 0'),"1":__('Is_system 1')}, formatter: Table.api.formatter.normal},
                        {field: 'ct_date', title: __('Ct_date')},
                        {field: 'up_date', title: __('Up_date')},
                        {field: 'delete', title: __('Delete'), searchList: {"0":__('Delete 0'),"1":__('Delete 1')}, formatter: Table.api.formatter.normal},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
